import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";

import { resolve } from 'path'

type ConfigType = {
  [k: string]: any
}
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
  console.log(`command: ${command};`, `mode: ${mode};`)
  const config: ConfigType = {
    plugins: [uni()],
    resolve: {
      alias: {
        '@': resolve(__dirname, './src')
      },
    },
  }

  if (mode === 'production') {
    // 发布时删除 console
    config.build = {
      minify: 'terser',
      terserOptions: {
        compress: {
          drop_console: true,
        },
      },
    }
  }
  console.log(config)
  return config
});
